<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of manipulasi
 *
 * @author Obi
 */
class M_pemesanan extends DataMapper {

    var $table = 'buyshare';
    var $key = 'id';

    function __construct() {
        parent::__construct();
    }

    //put your code here
    function insert($form) {
        $this->db->insert($this->table, $form);
    }

    function update($form, $id) {
        $this->db->where($this->key, $id);
        $this->db->update($this->table, $form);
    }

    function delete($id) {
        $this->db->where($this->key, $id);
        $this->db->delete($this->table);
    }

    function select_data() {
        #$sql = "select
        #        pemesanan.*, concat( member.nama_depan,' ', member.nama_belakang) as nama_member
        #    from  
        #        pemesanan, member 
        #    where
        #        pemesanan.id_member=member.id order by pemesanan.date desc";
        #
        #$query = $this->db->query($sql);
        #return $query->result();
    }

    function select_data_member($id = NULL) {
        #$sql = "select
        #        pemesanan.*, concat( member.nama_depan,' ', member.nama_belakang) as nama_member
        #    from  
        #        pemesanan, member 
        #    where
        #        pemesanan.id_member=member.id and member.id='$id' order by pemesanan.date desc";
        #
        #$query = $this->db->query($sql);
        #return $query->result();
    }

    function select_data_det($id = NULL) {
        #$sql = "select 
        #            pemesanan.*,
        #            (select nama_provinsi from provinsi where id=pemesanan.id_provinsi) as nama_provinsi1,
        #            (select nama_kota from kota where id=pemesanan.id_kota) as nama_kota1,
        #            (select nama_provinsi from provinsi where id=pemesanan.id_provinsi) as nama_provinsi2,
        #            (select nama_kota from kota where id=pemesanan.id_kota2) as nama_kota2,
        #            mitra_pengiriman.nama_mitra as nama_mitra
        #        from 
        #            pemesanan,
        #            mitra_pengiriman
        #        where
        #            pemesanan.id_mitra_kirim=mitra_pengiriman.id and 
        #            pemesanan.id='$id' ";
        #
        #$query = $this->db->query($sql);
        #return $query->row();
    }

    //untuk data pengiriman
    function select_data_kirim($id = NULL) {
        #$sql = "select 
        #            pemesanan.*,
        #            (select nama_provinsi from provinsi where id=pemesanan.id_provinsi) as nama_provinsi1,
        #            (select nama_kota from kota where id=pemesanan.id_kota) as nama_kota1,
        #            (select nama_provinsi from provinsi where id=pemesanan.id_provinsi) as nama_provinsi2,
        #            (select nama_kota from kota where id=pemesanan.id_kota2) as nama_kota2,
        #            mitra_pengiriman.nama_mitra as nama_mitra
        #        from 
        #            pemesanan,
        #            mitra_pengiriman
        #        where
        #            pemesanan.id_mitra_kirim=mitra_pengiriman.id";
        #
        #$query = $this->db->query($sql);
        #return $query->result();
    }

    function select_private_data($id_member = NULL) {
        #$sql = "select
        #            * 
        #        from 
        #            pemesanan
        #        where
        #            pemesanan.id_member='$id_member' and status='0'";
        #
        #$query = $this->db->query($sql);
        #return $query->result();
    }

    function select_data_report($date1 = NULL, $date2 = NULL) {

        #$sql = "select
        #        pemesanan.*, concat( member.nama_depan,' ', member.nama_belakang) as nama_member
        #    from  
        #        pemesanan, member 
        #    where
        #        pemesanan.id_member=member.id and
        #        pemesanan.date BETWEEN '$date1' AND '$date2'
        #    order by pemesanan.date desc";
        #
        #$query = $this->db->query($sql);
        #return $query->result();
    }

    function grafix_sukses() {

        #$sql = "select 
        #                DATE_FORMAT(date, '%M-%Y') as tanggal,
        #                count(id) as jml_transaksi
        #        from
        #                pemesanan
        #        where
        #                status = 2
        #        group by 
        #                DATE_FORMAT(date, '%m-%Y')";
        #
        #$query = $this->db->query($sql);
        #return $query->result();
    }

    function grafix_gagal() {

        #$sql = "select 
        #                DATE_FORMAT(date, '%M-%Y') as tanggal,
        #                count(id) as jml_transaksi
        #        from
        #                pemesanan
        #        where
        #                status != 2
        #        group by 
        #                DATE_FORMAT(date, '%m-%Y')";
        #
        #$query = $this->db->query($sql);
        #return $query->result();
    }

}

?>
